package org.webautotest.reservation;


import cn.bmyi.webautotest.aimee.BrowserEmulator;
/**
 * 封装我的体检预约-预约详情页面操作及页面元素
 * @author gaowen
 *
 */
public class ResvDetailsPage
{
	public BrowserEmulator browser;
	public String url;
	public static class PageElement
	{
		public static final String SEARCH_TITLE_XPATH="/html/body/div/header/div";//标题栏（预约详情）
		public static final String SEARCH_ORDERTITLE_XPATH="/html/body/div/div/div[1]/div/h3";//预约单标题（上海杨浦体检中心）
		public static final String SEARCH_PHONELOGO_XPATH="/html/body/div/div/div[1]/a";//电话图标按钮
		public static final String SEARCH_CANCELBUTTON_XPATH="/html/body/div/div/a/span";//取消预约按钮
		public static final String SEARCH_POPTITLE_XPATH="/html/body/div[3]/div[1]";//弹窗标题 （确定操作）
		public static final String SEARCH_POPTEXTLINE1_XPATH="/html/body/div[3]/div[2]";//弹窗文字 （您确定要取消这条预约单吗？\n取消后无法撤销操作）
		public static final String SEARCH_POPCONFIRMBUTTON_XPATH="/html/body/div[3]/div[3]/a[2]";//弹窗确认按钮
		public static final String SEARCH_POPCANCELBUTTON_XPATH="/html/body/div[3]/div[3]/a[1]";//弹窗取消按钮
		public static final String SEARCH_MAP_XPATH="//*[@id=\"mask\"]";//地图
		public static final String SEARCH_BACKBUTTON_XPATH="/html/body/div/header/div/a";//返回按钮
	}
	
	public ResvDetailsPage(BrowserEmulator browser)
	{
		this.browser=browser;
	}
	
	/**
	 * 获取标题栏标题
	 * @return 标题
	 */
	public String getTitle()
	{
		return browser.findElement("xpath", PageElement.SEARCH_TITLE_XPATH).getText();
	}
	
	/**
	 * 获取订单标题
	 * @return 订单标题
	 */
	public String getOrderTitle()
	{
		return browser.findElement("xpath", PageElement.SEARCH_ORDERTITLE_XPATH).getText();
	}
	
	/**
	 * 点击电话图标
	 */
	public void clickPhoneLogo()
	{
		browser.findElement("xpath", PageElement.SEARCH_PHONELOGO_XPATH).click();
	}
	
	/**
	 * 点击取消预约按钮
	 */
	public void clickCancelButton()
	{
		browser.findElement("xpath", PageElement.SEARCH_CANCELBUTTON_XPATH).click();
	}
	
	/**
	 * 获取弹窗标题
	 * @return 弹窗标题
	 */
	public String getPopTitle()
	{
		return browser.findElement("xpath", PageElement.SEARCH_POPTITLE_XPATH).getText();
	}
	
	/**
	 * 获取弹窗第一行内容
	 * @return 弹窗第一行内容
	 */
	public String getPopText1()
	{
		return browser.findElement("xpath", PageElement.SEARCH_POPTEXTLINE1_XPATH).getText();
	}
	
	
	/**
	 * 点击弹窗取消按钮
	 */
	public void clickPopCancelButton()
	{
		browser.findElement("xpath", PageElement.SEARCH_POPCANCELBUTTON_XPATH).click();
	}
	
	/**
	 * 点击弹窗确认按钮
	 */
	public void clickConfirmButton()
	{
		browser.findElement("xpath", PageElement.SEARCH_POPCONFIRMBUTTON_XPATH).click();
	}
	
	/**
	 * 查看地图是否可见
	 * @return true：可见；false：不可见
	 */
	public Boolean isMapDisplay()
	{
		return browser.findElement("xpath", PageElement.SEARCH_MAP_XPATH).isDisplayed();
	}
	
	/**
	 * 点击返回按钮
	 */
	public void clickBackButton()
	{
		browser.findElement("xpath", PageElement.SEARCH_BACKBUTTON_XPATH).click();
	}
}
